/*
 * Copyright (c) 2016 4PX Information Technology Co.,Ltd. All rights reserved.
 */
package com.commerceerp.system.api.fourpx;

import com.alibaba.fastjson.JSONObject;
import com.commerceerp.system.util.HttpClientUtil;

/**
 * 
 * @author fc
 * @date 2018年12月13日
 */
public class MainTest {

    // 沙箱环境
    private static String appKey = "63a7a7d3-d9db-496b-84e0-e61063e0b8ca";
    private static String appSecrert = "484516da-fe4b-4505-b5f9-bcec9d1650ca";
    // 根据仓库代码查询4PX物流产品信息
    private static String method = "com.basis.logistics_product.getlist";
    private static String requestUrl = "http://open.sandbox.4px.com/router/api/service";

    
    public static void main(String[] args) {
        JSONObject data = new JSONObject();
        data.put("service_code", "F");
        data.put("category_code", "end");
        data.put("source_position_code", "CNHKGB");
        data.put("dest_position_code", "");
        data.put("dest_country_code", "US");
        data.put("dest_post_code", "");
        data.put("dest_state_name", "");
        data.put("dest_city_name", "");

        //平台客户必填
        String accessToken = "";
        ApiRequest apiRequest = new ApiRequest(method, appKey, appSecrert, data.toJSONString());
        // 生成签名值
        apiRequest.generateSignValue();
        // 生成请求路径
        String postJson = null;
        try {
            String url = apiRequest.generateUrl(requestUrl, accessToken);
            postJson = HttpClientUtil.postJson(url, data.toJSONString());
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("返回结果"+postJson);
    }
    
    
}
